﻿using AntdUI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TCOChart
{
    public partial class DataEntryForm : Form
    {
        public DataEntryForm()
        {
            InitializeComponent();
            InitData();
        }

        private void InitData()
        {
            datePicker2.MinDate = DateTime.Now.AddDays(-7);
            datePicker3.MaxDate = DateTime.Now.AddDays(7);
            // 日期上显示徽标
            datePicker1.BadgeAction = dates =>
            {
                return new List<AntdUI.DateBadge>
                {
                    new AntdUI.DateBadge(DateTime.Now.AddDays(5).ToString("yyyy-MM-dd"),99,Color.Red),
                    new AntdUI.DateBadge(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"),2,Color.Red),
                    new AntdUI.DateBadge(DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd"),8,Color.FromArgb(14, 176, 201)),
                };
            };

            TreeItem[] items = new TreeItem[5]
           {
                new TreeItem(){Text = "child1"},
                new TreeItem(){Text = "child2"},
                new TreeItem(){Text = "child3"},
                new TreeItem(){Text = "child4"},
                new TreeItem(){Text = "child5"},
           };


            TreeItem item = new TreeItem()
            {
                Text = "parent3",
            };
            item.Sub.AddRange(items);

            tree1.Items.Add(item);
        }

        private string slider1_ValueFormatChanged(object sender, AntdUI.IntEventArgs e)
        {
            return e.Value + "℃";
        }

        private void DataEntryForm_Load(object sender, EventArgs e)
        {
            AntdUI.TooltipComponent tooltip = new AntdUI.TooltipComponent()
            {
                Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
                ArrowAlign = AntdUI.TAlign.Left,
            };
            tooltip.SetTip(button_tooltip, "this is a tip");

        }

        private void button_preview1_Click(object sender, EventArgs e)
        {
            Preview.open(new Preview.Config(this, Properties.Resources.bg1));
        }

        private void button_preview2_Click(object sender, EventArgs e)
        {
            Preview.open(new Preview.Config(this, new List<Image>()
            {
                Properties.Resources.bg1, Properties.Resources.关闭, Properties.Resources.bg1
            }));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            AntdUI.Drawer.open(new AntdUI.Drawer.Config(this, new Form1() { Size = new Size(300, 300) }) { 
                Align = TAlignMini.Left,
                Mask = true,
                DisplayDelay = 0,  // 延迟弹出时间
            });
        }
    }
}
